﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;

namespace MarketMS
{
    /// <summary>
    /// 数据库操作抽象类
    /// </summary>
    public abstract class DBHelper
    {
        /// <summary>
        /// 执行INSERT、UPDATE、DELETE操作并返回受影响行数
        /// </summary>
        /// <param name="sql">要执行的SQL语句</param>
        /// <returns>受影响行数</returns>
        public abstract int ExecuteSQL(string sql);
        /// <summary>
        /// 执行SELECT语句并返回首行首列值
        /// </summary>
        /// <param name="sql">要执行的SQL语句</param>
        /// <returns>首行首列值</returns>
        public abstract object ExecuteScalar(string sql);

        /// <summary>
        /// 执行SELECT语句并返回查询结果读取器
        /// </summary>
        /// <param name="sql">要执行的SQL语句</param>
        /// <returns>查询结果读取器</returns>
        public abstract DbDataReader GetReader(string sql);

        /// <summary>
        /// 执行SELECT语句并返回查询结果表
        /// </summary>
        /// <param name="sql">要执行的SQL语句</param>
        /// <returns>查询结果表</returns>
        public abstract DataTable GetTable(string sql);

        public abstract void Open();

        public abstract void Close();
    }
}
